<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // exec()    用正则表达式检索字符串, 将字符串中符合规则的某个或某点字符取出,放到新数组中

    // 惰性匹配  =>在条件允许的前提下，会匹配尽可能少的字符 

    // 如何进行惰性匹配 => 在重复性量词之后在添加一个? (惰性匹配)


    var str = "abcdefghijklmn";
    var reg = /\w+?/;// 字母数字下划线一个或多个
    console.log(reg.exec(str));

    var str = "abcdefghijklmn";
    var reg = /\w*?/;// 字母数字下划线0个或多个
    console.log(reg.exec(str));

    var str = "abcdefghijklmn";
    var reg = /\w{2,}?/;// 字母数字下划线2个或多个
    console.log(reg.exec(str));



    var str = "abcdefghijklmn";
    var reg = /\w??/;// 字母数字下划线0个或1个
    console.log(reg.exec(str));

    var str = "abcdefghijklmn";
    var reg = /\w{2,5}?/;// 字母数字下划线2个或5个
    console.log(reg.exec(str));







</script>

</html>